package com.monte.persistence;

import java.util.List;

import com.monte.common.Pagination;

/**
 * @描述:查询执行器(MyBatis)
 * @author FengMy
 * @since 2013-3-6
 */
public interface QueryExecutor {

	/**
	 * 执行分页查询(mybatis)
	 * @param mapper
	 * @param pagination
	 * @param param
	 * @return
	 */
	<T> Pagination<T> execQuery(String mapper,
			Pagination<T> pagination, Object param);

	/**
	 * 执行列表查询(mybatis)
	 * @param mapper
	 * @param param
	 * @param type
	 * @return
	 */
	<T> List<T> execQuery(String mapper,
			Object param, Class<T> type);

	/**
	 * 查询结果数(mybatis)
	 * @param mapper
	 * @param param
	 * @return
	 */
	int execCount(String mapper, Object param);

	/**
	 * 获取惟一结果(mybatis)
	 * @param mapper
	 * @param param
	 * @param type
	 * @return when result is null,should be throws exception
	 */
	<T> T selectSingleResult(String mapper, Object param,
			Class<T> type);

	/**
	 * 查询惟一实体
	 * @param type
	 * @param id
	 * @return return null if result is null
	 */
	<T> T selectSingleEntity(Class<T> type, Object id);
	
	/**
	 * 调用命令,此处只支持jpa事务
	 * @param command
	 * @return
	 */
	Object callCommand(PersistenceCommand command);
}